package com.bw.zg2.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.bw.zg2.base.BaseResult
import com.bw.zg2.base.BaseViewModel
import com.bw.zg2.bean.LoginBean
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

/**
 *
 * @ClassName: LoginViewModel
 * @Description: java类作用描述
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/12 11:55 AM
 * @Version: 1.0
 */
class RegisterViewModel : BaseViewModel() {

    val registerLiveData = MutableLiveData<BaseResult<LoginBean>>()
    fun register(map: Map<String, String>) {
        // 发送网络请求，实现注册
        viewModelScope.launch {
            withContext(Dispatchers.IO) {
                val baseResult = apiService.register(map)
                registerLiveData.postValue(baseResult)
            }

        }

    }
}